import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';

// 引入数据库的及配置文件
import { TypeOrmModule } from '@nestjs/typeorm';
import { UserModule } from './user/user.module';
import { User } from './user/user.entity';
import { PhotoModule } from './photo/photo.module';
import { Photo } from './photo/photo.entity';
import { CategoryModule } from './category/category.module';
import { FollowModule } from './follow/follow.module';
import { PhotoLikeModule } from './photo-like/photo-like.module';
import { Category } from './category/category.entity';
import { Follow } from './follow/follow.entity';
import { PhotoLike } from './photo-like/photo-like.entity';
import { AuthModule } from './auth/auth.module';

@Module({
  imports: [
    TypeOrmModule.forRoot({
      type: 'mysql',
      host: '39.104.60.212',
      port: 3306,
      username: 'photos',
      password: '741852963.',
      database: 'photos',
      entities: [User, Photo, Category, Follow, PhotoLike],
      migrations: ['migration/*.ts'],
      timezone: 'UTC',
      charset: 'utf8mb4',
      multipleStatements: true,
      dropSchema: false,
      synchronize: false, // 是否自动将实体类同步到数据库
      logging: true,
    }),
    UserModule,
    PhotoModule,
    CategoryModule,
    FollowModule,
    PhotoLikeModule,
    AuthModule
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule { }
